package com.heitian.ssm.model;

import java.util.HashMap;
import java.util.Map;


public class JsonResponse {

    public static String SUCCESS = "8000";
    public static String RAW_DATA_INPUT_EXPIRED = "8101";
    public static String WRONG_LOGIN_INFO_DRIVER = "8102";
    public static String WRONG_LOGIN_INFO_USER = "8103";
    public static String File_NOT_EXIST = "8104";
    public static String REPORT_EXIST = "8105";
    //LOGIN REGISTER

    //    public static String MOBILE_EXIST = "8101";
//    public static String MOBILE_NOT_EXIST = "8102";
//    public static String WRONG_PASSCODE = "8103";
//    public static String SESSION_EXPIRED=  "8104";
//    public static String NEED_LOGIN =  "8105";
    public static String LOGIN_FAILED =  "8106";
    public static String UPDATE_PASSWORD_FAILED = "8107";
    public static String WRONG_OPEN_ID = "8108";
    public static String FIRST_OAUTH_NEED_MOBILE = "8109";
    public static String NON_EXIST_MEMBER = "8110";
    public static String NON_EXIST_COACH = "8111";
    public static String NON_EXIST_GYM = "8112";
    public static String HAS_PASSWORD_YET = "8113";
    public static final String CERTIFICATE_INVALID = "8114";
    public static String OLD_AND_NEW_PASSWORD_IDENTICAL = "8601";
    public static String PASSWORD_INEQUALITY = "8602";

    //LESSON COURSE COACH GYM

    public static String WRONG_COACH_ID = "8114";
    public static String UNBINDED_COACH = "8115";
    public static String BIND_COACH_REPEATLY = "8116";
    public static String NON_EXIST_COURSE = "8117";
    public static String WRONG_DAY_OF_WEEK = "8118";
    public static String NON_EXIST_LESSON_TEMPLATE = "8119";
    public static String WRONG_CONTRACT_ID="8120";
    public static String COACH_CAN_NOT_BE_DATED = "8121";
    public static String COURSE_TYPE_NOT_MATCHED = "8122";
    public static String BIND_COACH_WITHOUT_AVAIL_PRIVATE_COURSE = "8123";
    public static String COORDINATE_MISSED = "8124";
    public static String PERMISSION_DENIED = "8125";
    public static String LESSON_OVER = "8126";
    public static String TOO_LATE_TO_CANCEL_LESSON = "8127";
    public static String LESSON_LATER = "8128";
    public static String WRONG_CLASS_TYPE = "8129";
    public static String NOT_EXIST_PACKAGE_LESSON = "8130";

    //PAYMENT RELATED

    public static String BEANS_NOT_ENOUGH = "8201";
    public static String BOOK_LESSON_REPEATLY = "8202";
    public static String BOOK_LESSON_BEYAND_AVAILABLE_TIMES = "8203";
    public static String COURSE_HAS_BEEN_USED = "8204";
    public static String NO_COURSE_BOUGHT = "8205";
    public static String BUY_ONE_COURSE_REPEATLY = "8206";
    public static String NON_EXIST_RECEIPT_ID = "8207";
    public static String COURSE_NOT_BOOKED_BEFORE_VERIFY ="8208";
    public static String NON_EXIST_LESSON = "8209";
    public static String INVALID_RECEIPT_STATUS = "8210";
    public static String NON_EXIST_RECEIPT = "8211";
    public static String INVALID_RECEIPT_UID ="8212";
    public static String NON_EXIST_GIFT_TEMPLATE="8213";
    public static String INVALID_COUPON_ID = "8214";
    public static String EXPIRED_COUPON = "8215";
    public static String NON_EXIST_GIFT="8216";
    public static String GIFT_NOT_BE_IN_VALID_PERIOD="8217";
    public static String COUPON_RUN_OUT="8218";
    public static String COUPON_HAS_RECEIVED="8219";
    public static String BOOK_LESSON_BEYAND_NUMBER_LIMIT = "8220";
    public static final String PACKAGE_LESSON_CAN_NOT_CANCEL = "8221";
    public static final String BUY_LESSON_FAIL = "8222";
    public static String NON_EXIST_EXCHANGE_CODE = "8223";
    public static String EXCHANGE_CODE_NOT_BE_IN_VALID_PERIOD = "8224";
    public static String EXCHANGE_CODE_RUN_OUT = "8225";
    public static String EXCHANGE_CODE_USED_TOO_MUCH = "8226";
    public static String EXIST_COACH = "8227";
    public static String EXIST_CONTRACT = "8228";

    //CONCURRENT OR LATENCY PROBLEMS

    public static String UPLOAD_FAILED =  "8401";
    public static String WRONG_DATE_FORMAT =  "8402";
    public static String COMMENT_YET =  "8403";
    public static String COMMENT_FAIL = "8404";

    public static String SEND_MESSAGE_FAIL = "8901";
    public static String SEND_MESSAGE_TOO_FREQUENTLY = "8902";
    public static String SEND_UNICAST_FAILED = "8903";

    private static Map<String, String> errorMap = new HashMap<String, String>();
    static{
        errorMap.put(SUCCESS, "success");
        errorMap.put(RAW_DATA_INPUT_EXPIRED, "一起填写过期啦");
        errorMap.put(WRONG_LOGIN_INFO_DRIVER, "司机登录失败");
        errorMap.put(WRONG_LOGIN_INFO_USER, "用户登录失败");
        errorMap.put(SEND_MESSAGE_FAIL, "send message failed");
        errorMap.put(File_NOT_EXIST, "行车报告不存在");
        errorMap.put(REPORT_EXIST, "行车报告已经存在");
//        errorMap.put(WRONG_PASSCODE, "wrong passcode.");
//        errorMap.put(MOBILE_EXIST, "mobile exist already!");
//        errorMap.put(MOBILE_NOT_EXIST, "mobile does not exist!");
        errorMap.put(SEND_MESSAGE_TOO_FREQUENTLY, "send message too frequently");
//        errorMap.put(SESSION_EXPIRED, "session expired, please login");
        errorMap.put(UPLOAD_FAILED, "upload file failed");
        errorMap.put(LOGIN_FAILED, "wrong mobile or password");
        errorMap.put(BEANS_NOT_ENOUGH, "beans not enough, please recharge");
        errorMap.put(BOOK_LESSON_BEYAND_AVAILABLE_TIMES, "book lesson beyand available times");
        errorMap.put(COURSE_HAS_BEEN_USED, "refund failed because course has been used");
        errorMap.put(UPDATE_PASSWORD_FAILED, "update password failed, wrong password");
        errorMap.put(WRONG_OPEN_ID, "wrong open id");
        errorMap.put(NO_COURSE_BOUGHT, "please buy course first");
        errorMap.put(BUY_ONE_COURSE_REPEATLY, "not need to buy the same course before using it up");
        errorMap.put(NON_EXIST_RECEIPT_ID, "course maybe returned or never be bought");
        errorMap.put(BOOK_LESSON_REPEATLY, "book lesson repeatly");
        errorMap.put(COURSE_NOT_BOOKED_BEFORE_VERIFY, "should book course before verify it");
        errorMap.put(WRONG_DATE_FORMAT, "wrong date fomat");
        errorMap.put(FIRST_OAUTH_NEED_MOBILE, "first oauth need mobile number");
        errorMap.put(NON_EXIST_LESSON, "lesson not exist");
        errorMap.put(INVALID_RECEIPT_STATUS, "invalid receipt status");
        errorMap.put(NON_EXIST_RECEIPT, "receipt not exist");
        errorMap.put(INVALID_RECEIPT_UID, "the receipt does not belong to the user");
        errorMap.put(INVALID_COUPON_ID, "please check the status/gymId of coupon");
        errorMap.put(EXPIRED_COUPON, "coupon expired");
        errorMap.put(COUPON_RUN_OUT, "there is no more coupon, be fastly next tiem");
        errorMap.put(GIFT_NOT_BE_IN_VALID_PERIOD, "coupon not be in valid period");
        errorMap.put(NON_EXIST_GIFT, "gift id not exist");
        errorMap.put(COUPON_HAS_RECEIVED, "you have received this coupon");
        errorMap.put(NON_EXIST_MEMBER, "wrong member id");
        errorMap.put(NON_EXIST_COACH, "wrong coach id");
        errorMap.put(WRONG_CLASS_TYPE, "wrong lesson type");
        errorMap.put(NON_EXIST_EXCHANGE_CODE, "wrong exchange code");
        errorMap.put(EXCHANGE_CODE_NOT_BE_IN_VALID_PERIOD, "exchange code has expired");
        errorMap.put(EXCHANGE_CODE_RUN_OUT, "exchange code has run out");
        errorMap.put(EXCHANGE_CODE_USED_TOO_MUCH, "exchange code has been used more than three times within a day");
        errorMap.put(SEND_UNICAST_FAILED, "push unicast failed");
        errorMap.put(WRONG_COACH_ID, "please check the coach info");
        errorMap.put(UNBINDED_COACH, "this coach does not belong to the gym");
        errorMap.put(BIND_COACH_REPEATLY, "does not need to bind repeatly");
        errorMap.put(NON_EXIST_COURSE, "course not exist, please check the courseId");
        errorMap.put(WRONG_DAY_OF_WEEK, "day of week should be 1~7");
        errorMap.put(NON_EXIST_LESSON_TEMPLATE, "lesson template does not exist, check the lessonTemplate id");
        errorMap.put(WRONG_CONTRACT_ID, "uncorrect contract id");
        errorMap.put(COACH_CAN_NOT_BE_DATED, "coachtype in contract should be private to date");
        errorMap.put(COURSE_TYPE_NOT_MATCHED, "course type not matched");
        errorMap.put(BIND_COACH_WITHOUT_AVAIL_PRIVATE_COURSE, "this gym does not have available private course");
        errorMap.put(COORDINATE_MISSED, "coordinate missed");
        errorMap.put(PERMISSION_DENIED, "permission denied");
        errorMap.put(HAS_PASSWORD_YET, "has password yet, no need to be set");
        errorMap.put(LESSON_OVER, "lesson over");
        errorMap.put(LESSON_LATER, "lesson later");
        errorMap.put(BOOK_LESSON_BEYAND_NUMBER_LIMIT, "beyand number limit of lesson");
        errorMap.put(TOO_LATE_TO_CANCEL_LESSON, "too late to cancel lesson");
        errorMap.put(COMMENT_YET, "this receipt has been commented");
        errorMap.put(PACKAGE_LESSON_CAN_NOT_CANCEL, "package lesson can not cancel");
        errorMap.put(BUY_LESSON_FAIL, "buy lesson fail");
        errorMap.put(COMMENT_FAIL, "comment fail");
        errorMap.put(NOT_EXIST_PACKAGE_LESSON, "not exist package lesson");
    }


    public JsonResponse(String errorCode, Object data) {
        this.errCode = errorCode;
        this.errMsg = errorMap.get(errorCode);
        this.data = data;
    }


    String errCode;
    public String getErrCode() {
        return errCode;
    }

    String errMsg;
    public String getErrMsg() {
        return errMsg;
    }

    Object data;
    public Object getData() {
        return data;
    }
}